import 'package:FiduMart/generated/json/base/json_convert_content.dart';
import 'package:FiduMart/core/network/information_newsDetail_entity.dart';

InformationNewsDetailEntity $InformationNewsDetailEntityFromJson(
    Map<String, dynamic> json) {
  final InformationNewsDetailEntity informationNewsDetailEntity = InformationNewsDetailEntity();
  final List<
      InformationNewsDetailContentList>? contentList = (json['contentList'] as List<
      dynamic>?)?.map(
          (e) =>
      jsonConvert.convert<InformationNewsDetailContentList>(
          e) as InformationNewsDetailContentList).toList();
  if (contentList != null) {
    informationNewsDetailEntity.contentList = contentList;
  }
  final String? createTime = jsonConvert.convert<String>(json['createTime']);
  if (createTime != null) {
    informationNewsDetailEntity.createTime = createTime;
  }
  final String? id = jsonConvert.convert<String>(json['id']);
  if (id != null) {
    informationNewsDetailEntity.id = id;
  }
  final int? realWatchNum = jsonConvert.convert<int>(json['realWatchNum']);
  if (realWatchNum != null) {
    informationNewsDetailEntity.realWatchNum = realWatchNum;
  }
  final String? shelfTime = jsonConvert.convert<String>(json['shelfTime']);
  if (shelfTime != null) {
    informationNewsDetailEntity.shelfTime = shelfTime;
  }
  final int? sort = jsonConvert.convert<int>(json['sort']);
  if (sort != null) {
    informationNewsDetailEntity.sort = sort;
  }
  final int? status = jsonConvert.convert<int>(json['status']);
  if (status != null) {
    informationNewsDetailEntity.status = status;
  }
  final int? topFlag = jsonConvert.convert<int>(json['topFlag']);
  if (topFlag != null) {
    informationNewsDetailEntity.topFlag = topFlag;
  }
  final String? typeId = jsonConvert.convert<String>(json['typeId']);
  if (typeId != null) {
    informationNewsDetailEntity.typeId = typeId;
  }
  final int? watchNum = jsonConvert.convert<int>(json['watchNum']);
  if (watchNum != null) {
    informationNewsDetailEntity.watchNum = watchNum;
  }
  return informationNewsDetailEntity;
}

Map<String, dynamic> $InformationNewsDetailEntityToJson(
    InformationNewsDetailEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['contentList'] = entity.contentList?.map((v) => v.toJson()).toList();
  data['createTime'] = entity.createTime;
  data['id'] = entity.id;
  data['realWatchNum'] = entity.realWatchNum;
  data['shelfTime'] = entity.shelfTime;
  data['sort'] = entity.sort;
  data['status'] = entity.status;
  data['topFlag'] = entity.topFlag;
  data['typeId'] = entity.typeId;
  data['watchNum'] = entity.watchNum;
  return data;
}

extension InformationNewsDetailEntityExt on InformationNewsDetailEntity {
  InformationNewsDetailEntity copyWith({
    List<InformationNewsDetailContentList>? contentList,
    String? createTime,
    String? id,
    int? realWatchNum,
    String? shelfTime,
    int? sort,
    int? status,
    int? topFlag,
    String? typeId,
    int? watchNum,
  }) {
    return InformationNewsDetailEntity()
      ..contentList = contentList ?? this.contentList
      ..createTime = createTime ?? this.createTime
      ..id = id ?? this.id
      ..realWatchNum = realWatchNum ?? this.realWatchNum
      ..shelfTime = shelfTime ?? this.shelfTime
      ..sort = sort ?? this.sort
      ..status = status ?? this.status
      ..topFlag = topFlag ?? this.topFlag
      ..typeId = typeId ?? this.typeId
      ..watchNum = watchNum ?? this.watchNum;
  }
}

InformationNewsDetailContentList $InformationNewsDetailContentListFromJson(
    Map<String, dynamic> json) {
  final InformationNewsDetailContentList informationNewsDetailContentList = InformationNewsDetailContentList();
  final String? content = jsonConvert.convert<String>(json['content']);
  if (content != null) {
    informationNewsDetailContentList.content = content;
  }
  final String? coverUrl = jsonConvert.convert<String>(json['coverUrl']);
  if (coverUrl != null) {
    informationNewsDetailContentList.coverUrl = coverUrl;
  }
  final String? lang = jsonConvert.convert<String>(json['lang']);
  if (lang != null) {
    informationNewsDetailContentList.lang = lang;
  }
  final String? newsDesc = jsonConvert.convert<String>(json['newsDesc']);
  if (newsDesc != null) {
    informationNewsDetailContentList.newsDesc = newsDesc;
  }
  final String? title = jsonConvert.convert<String>(json['title']);
  if (title != null) {
    informationNewsDetailContentList.title = title;
  }
  return informationNewsDetailContentList;
}

Map<String, dynamic> $InformationNewsDetailContentListToJson(
    InformationNewsDetailContentList entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['content'] = entity.content;
  data['coverUrl'] = entity.coverUrl;
  data['lang'] = entity.lang;
  data['newsDesc'] = entity.newsDesc;
  data['title'] = entity.title;
  return data;
}

extension InformationNewsDetailContentListExt on InformationNewsDetailContentList {
  InformationNewsDetailContentList copyWith({
    String? content,
    String? coverUrl,
    String? lang,
    String? newsDesc,
    String? title,
  }) {
    return InformationNewsDetailContentList()
      ..content = content ?? this.content
      ..coverUrl = coverUrl ?? this.coverUrl
      ..lang = lang ?? this.lang
      ..newsDesc = newsDesc ?? this.newsDesc
      ..title = title ?? this.title;
  }
}